package com.masterclient.app.modules.aftersale.contract;

import com.eoner.baselib.container.CommonBaseResponse;
import com.eoner.baselib.presenter.ThrowableConsumer;
import com.eoner.baselibrary.bean.aftersale.AfterSaleServeInfoBean;
import com.masterclient.app.httpservice.RetrofitUtil2;

import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/08/27
*/
public class AfterSaleServePresenter extends AfterSaleServeContract.Presenter{

    @Override
    public void getAfterSaleServeList(String status, String page, String pageSize) {
        Observable<CommonBaseResponse<AfterSaleServeInfoBean>> observable = RetrofitUtil2.getInstance().getAfterSaleServeList(status,page,pageSize);
        Disposable disposable = toSubscribe(observable, (Consumer<CommonBaseResponse<AfterSaleServeInfoBean>>) bean -> {
            if(bean.getCode() == 0){
                mView.showAfterSaleServeInfo(bean.getData());
            }else {
                mView.showFail(bean.getMsg());
            }
        }, new ThrowableConsumer());
        mRxManager.add(disposable);
    }
}